package com.cjm.one.model.coupon.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

import com.cjm.one.model.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
 * 优惠券信息
 * @TableName coupon_info
 */
@TableName(value ="coupon_info")
@Data
public class CouponInfo extends BaseEntity {
    /**
     * id
     */
//    @TableId(type = IdType.AUTO)
//    private Long id;

    /**
     * 优惠卷类型 1 现金券 2 折扣
     */
    @Schema(description = "优惠卷类型 1 现金券 2 折扣")
    @TableField("coupon_type")
    private Integer couponType;

    /**
     * 优惠卷名字
     */
    @Schema(description = "优惠卷名字")
    @TableField("name")
    private String name;

    /**
     * 金额
     */
    @Schema(description = "金额")
    @TableField("amount")
    private BigDecimal amount;

    /**
     * 折扣：取值[1 到 10]
     */
    @Schema(description = "折扣：取值[1 到 10]")
    @TableField("discount")
    private BigDecimal discount;

    /**
     * 使用门槛 0->没门槛
     */
    @TableField("condition_amount")
    @Schema(description = "使用门槛 0->没门槛")
    private BigDecimal conditionAmount;

    /**
     * 发行数量，0->无限制
     */
    @TableField("publish_count")
    @Schema(description = "发行数量，0->无限制")
    private Integer publishCount;

    /**
     * 每人限领张数，0-不限制 1-限领1张 2-限领2张
     */
    @Schema(description = "每人限领张数，0-不限制 1-限领1张 2-限领2张")
    @TableField("per_limit")
    private Integer perLimit;

    /**
     * 已使用数量
     */
    @Schema(description = "已使用数量")
    @TableField("use_count")
    private Integer useCount;

    /**
     * 使用范围[1->全场通用；2->指定分类；3->指定商品]
     */
    @Schema(description = "使用范围[1->全场通用；2->指定分类；3->指定商品]")
    @TableField("range_type")
    private Integer rangeType;

    /**
     * 领取数量
     */
    @Schema(description = "领取数量")
    @TableField("receive_count")
    private Integer receiveCount;

    @Schema(description = "乐观锁")
    @TableField("version")
    @JsonIgnore
    private Integer version;

    /**
     * 过期时间
     */
    @Schema(description = "过期时间")
    @TableField("expire_time")
    private LocalDateTime expireTime;

    /**
     * 优惠券描述
     */
    @Schema(description = "优惠券描述")
    @TableField("description")
    private String description;

    /**
     * 开始领取的时间
     */
    @Schema(description = "开始领取的时间")
    @TableField("start_time")
    private LocalDateTime startTime;

    /**
     * 可以领取的结束时间
     */
    @Schema(description = "可以领取的结束时间")
    @TableField("end_time")
    private LocalDateTime endTime;

    /**
     * 状态[0-未发布，1-已发布， -1-已过期]
     */
    @Schema(description = "状态[0-未发布，1-已发布， -1-已过期]")
    @TableField("status")
    private Integer status;



    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CouponInfo other = (CouponInfo) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCouponType() == null ? other.getCouponType() == null : this.getCouponType().equals(other.getCouponType()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
            && (this.getDiscount() == null ? other.getDiscount() == null : this.getDiscount().equals(other.getDiscount()))
            && (this.getConditionAmount() == null ? other.getConditionAmount() == null : this.getConditionAmount().equals(other.getConditionAmount()))
            && (this.getPublishCount() == null ? other.getPublishCount() == null : this.getPublishCount().equals(other.getPublishCount()))
            && (this.getPerLimit() == null ? other.getPerLimit() == null : this.getPerLimit().equals(other.getPerLimit()))
            && (this.getUseCount() == null ? other.getUseCount() == null : this.getUseCount().equals(other.getUseCount()))
            && (this.getRangeType() == null ? other.getRangeType() == null : this.getRangeType().equals(other.getRangeType()))
            && (this.getReceiveCount() == null ? other.getReceiveCount() == null : this.getReceiveCount().equals(other.getReceiveCount()))
            && (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
            && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
            && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCouponType() == null) ? 0 : getCouponType().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
        result = prime * result + ((getDiscount() == null) ? 0 : getDiscount().hashCode());
        result = prime * result + ((getConditionAmount() == null) ? 0 : getConditionAmount().hashCode());
        result = prime * result + ((getPublishCount() == null) ? 0 : getPublishCount().hashCode());
        result = prime * result + ((getPerLimit() == null) ? 0 : getPerLimit().hashCode());
        result = prime * result + ((getUseCount() == null) ? 0 : getUseCount().hashCode());
        result = prime * result + ((getRangeType() == null) ? 0 : getRangeType().hashCode());
        result = prime * result + ((getReceiveCount() == null) ? 0 : getReceiveCount().hashCode());
        result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
        result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(this.getId());
        sb.append(", couponType=").append(couponType);
        sb.append(", name=").append(name);
        sb.append(", amount=").append(amount);
        sb.append(", discount=").append(discount);
        sb.append(", conditionAmount=").append(conditionAmount);
        sb.append(", publishCount=").append(publishCount);
        sb.append(", perLimit=").append(perLimit);
        sb.append(", useCount=").append(useCount);
        sb.append(", rangeType=").append(rangeType);
        sb.append(", receiveCount=").append(receiveCount);
        sb.append(", expireTime=").append(expireTime);
        sb.append(", description=").append(description);
        sb.append(", startTime=").append(startTime);
        sb.append(", endTime=").append(endTime);
        sb.append(", status=").append(status);
        sb.append(", createTime=").append(this.getCreateTime());
        sb.append(", updateTime=").append(this.getUpdateTime());
        sb.append(", isDeleted=").append(this.getIsDeleted());
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}